﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="frmEstrenos.aspx.cs" Inherits="WebCinesItech.frmEstrenos" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
 <script src="http://code.jquery.com/jquery-1.7.js" type="text/javascript"></script>
    <script src="Scripts/jquery-1.4.4.min.js" type="text/javascript"></script>
<script type="text/javascript">

    $(document).ready(function () {
        //jQuery.support.cors = true;
        $.ajax({
            type: "GET",
            url: "http://localhost:49911/Generos.svc/Generos",
            data: "{}",
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            processdata: true,
            success: function (data) {
                alert("bien");
                var i = 0;
                var ddl = $("#<%=ddlGeneros.ClientID%>");
                ddl.append($('<option></option>').val('0').html('::Seleccione Genero::'));
                $.each(data, function () {
                    //$("#Select1").append($("<option></option>").attr("value", data[i].Codcine).text(data[i].Nombre));
                    //ddl.append($('<option></option>').val(data[i].Codcine).html(data[i].Nombre));
                    ddl.append($("<option></option>").attr("value", data[i].Codgenero).text(data[i].Descripcion));
                    i++;
                });
            },
            error: function (err) {
                alert("Errorr");
            }
        });

        $("#<%=ddlGeneros.ClientID%>").change(function () {
            //monedadesc = $('#ctl00_ContentPlaceHolder1_ddlMoneda option:selected').html()
            genero = $("#<%=ddlGeneros.ClientID%>").val();
            //alert(moneda);

            $.ajax({
                type: "GET",
                url: "http://localhost:49911/Estrenos.svc/Estrenos/" + genero,
                data: "{}",
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                processdata: true,
                success: function (data) {
                    //alert("bien");
                    var i = 0;
                    var tbl = "<table ><tr class='StyleGrilla'><td>Titulo</td><td>Descripción</td><td>Calificacion</td><td>Categoria</td><td>Duracion</td><td></td></tr>";
                    $.each(data, function () {
                        tbl += "<tr>";
                        tbl += "<td>" + data[i].Titulo + "</td><td>" + data[i].Descripcion + "</td><td>" + data[i].Calificacion + "</td><td>" + data[i].Categoria + " </td><td>" + data[i].Duracion + " - MIN.</td><td><img src='img/" + data[i].PeliculaID + ".jpg' /></td>";
                        tbl += "</tr>";
                        i++;
                    });
                    tbl += "</table>";
                    $("#divContenido").html(tbl);
                },
                error: function (err) {
                    alert("Errorr");
                }
            });

        });

    });

</script>

</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<div>
    <table cellpadding="0" cellspacing="0" class="style1">
    <tr>
        <td>
            
            &nbsp;</td>
        <td>
            Generos:</td>
        <td>
             <asp:DropDownList ID="ddlGeneros" runat="server" >
                </asp:DropDownList> 
            &nbsp;</td>
        <td>
            &nbsp;</td>
    </tr>
    <tr>
        <td>
            &nbsp;</td>
        <td colspan="2">
        <div id="divContenido"></div>
        </td>
        <td>
            &nbsp;</td>
    </tr>
    <tr>
        <td>
            &nbsp;</td>
        <td>
            &nbsp;</td>
        <td>
            &nbsp;</td>
        <td>
            &nbsp;</td>
    </tr>
    <tr>
        <td>
           
            </td>
        <td>
            &nbsp;</td>
        <td>
            &nbsp;</td>
        <td>
            &nbsp;</td>
    </tr>
</table>
</div>

</asp:Content>
